import {createStore,compose,applyMiddleware} from 'redux';
import reducer from './reducer';
import thunk from 'redux-thunk';
import {routerMiddleware} from 'react-router-redux';

//新增数据持久
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage/session'
import immutableTransform from "redux-persist-transform-immutable";
const persistConfig = {
  transforms: [immutableTransform()],
  key:"root",
  storage
}
const persistedReducer = persistReducer(persistConfig, reducer)


let createHistory = require('history').createHashHistory;
let history = createHistory();   // 初始化history
let routerWare = routerMiddleware(history);
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
export const store =createStore(persistedReducer,composeEnhancers(applyMiddleware(thunk,routerWare)));
 
export const persistor = persistStore(store)